home *** CD-ROM | disk | FTP | other *** search
- // Copyright (C) 1997-2002 Alias|Wavefront,
- // a division of Silicon Graphics Limited.
- //
- // The information in this file is provided for the exclusive use of the
- // licensees of Alias|Wavefront. Such users have the right to use, modify,
- // and incorporate this code into other products for purposes authorized
- // by the Alias|Wavefront license agreement, without fee.
- //
- // ALIAS|WAVEFRONT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
- // INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
- // EVENT SHALL ALIAS|WAVEFRONT BE LIABLE FOR ANY SPECIAL, INDIRECT OR
- // CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
- // DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
- // TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
- // PERFORMANCE OF THIS SOFTWARE.
- //
- //
- // Alias|Wavefront Script File
- // MODIFY THIS AT YOUR OWN RISK
- //
- // Creation Date: Sept 1996
- // Author: Lonnie Li
- //
- // Description:
- // This script performs various GUI startup related tasks.
- // It is run only in GUI mode and not batch mode.
- //
- // Input Arguments:
- // None.
- //
- // Return Value:
- // None.
- //
- // Note:
- // None.
- //
-
- //Object Details Procedures
- //
- //Backfaces
- //Smoothness (Nurbs and Subdivs only)
- //Instance
- //Display Layer
-
- //Command scripts
- //
- //Note: Due to the behaviour of the filterExpand command, code has been added
- // to circumvent "N/A" return value when an intermediate node is selected
- // in a given hierarchy. (ie. Parent nodes) The filterExpand command filters
- // out only the leaf nodes of the hierarchy, thus returning only the shapes
- // of any parent nodes, followed by the children of the node, in that order.
- // It is to be noted that filterExpand returns the shape of the currently
- // selected parent node in the string array, so a check is made to
- // ensure the main selection objects refer to the same object.
- //
- // This relates to both objectDetailsBackfaces() and objectDetailsSmoothness().
- //
- global proc string objectDetailsBackfaces()
- {
- string $result;
- int $hasResult = false;
-
- global int $gSelectMeshesBit;
- global int $gSelectNurbsSurfacesBit;
-
- string $selectedObjects[] = `ls -sl -o`;
- string $mainObject;
- string $mainShape;
- int $aSelectedObjectExists = 0;
-
- int $hasChildren = 0;
- int $isValid = 0;
-
- if (size($selectedObjects) > 0)
- {
- $mainObject = $selectedObjects[ (size($selectedObjects) - 1) ];
- $aSelectedObjectExists = 1;
-
- //Check if this node has any children (ie. it is a parent node)
- string $children[] = `listRelatives -c $mainObject`;
- string $shapes[] = `listRelatives -s $mainObject`;
-
- $mainShape = $shapes[0];
-
- if (size($children) > 1)
- {
- $hasChildren = 1;
- }
- else if (size($children) == 1)
- {
- if ($mainShape != $children[0])
- {
- $hasChildren = 1;
- }
- }
- }
-
- string $surface;
-
- string $meshSurfaces[] = `filterExpand -sm $gSelectMeshesBit
- $selectedObjects`;
-
- int $aSelectedMeshSurfaceExists = 0;
-
- if (size($meshSurfaces) > 0)
- {
- if ($hasChildren)
- {
- for ($surface in $meshSurfaces)
- {
- if ($mainShape == $surface)
- {
- $isValid = 1;
- break;
- }
- }
- }
- else if ($meshSurfaces[ (size($meshSurfaces) - 1) ] == $mainObject)
- {
- $isValid = 1;
- }
- $aSelectedMeshSurfaceExists = 1;
- }
-
- string $nurbsSurfaces[] = `filterExpand -sm $gSelectNurbsSurfacesBit
- $selectedObjects`;
- int $aSelectedNurbsSurfaceExists = 0;
-
- if (size($nurbsSurfaces) > 0)
- {
- if ($hasChildren)
- {
- for ($surface in $nurbsSurfaces)
- {
- if ($mainShape == $surface)
- {
- $isValid = 1;
- break;
- }
- }
- }
- else if ($nurbsSurfaces[ (size($nurbsSurfaces) - 1) ] == $mainObject)
- {
- $isValid = 1;
- }
- $aSelectedNurbsSurfaceExists = 1;
- }
-
- if ($aSelectedObjectExists)
- {
- if ($aSelectedMeshSurfaceExists && $isValid)
- {
- int $backfaces[] = `polyOptions -q -bc $mainObject`;
- if ($backfaces[0])
- {
- $result = "On";
- }
- else
- {
- $result = "Off";
- }
- $hasResult = true;
- }
- else if ($aSelectedNurbsSurfaceExists && $isValid)
- {
- if (!`displayCull -q -bfc $mainObject`)
- {
- $result = "On";
- }
- else
- {
- $result = "Off";
- }
- $hasResult = true;
- }
- }
-
- if (!$hasResult)
- {
- //No selected objects or no selected objects of valid type
- $result = "N/A";
- }
-
- return $result;
- }
-
- global proc string objectDetailsSmoothness()
- {
- string $result;
- int $hasResult = false;
-
- global int $gSelectNurbsSurfacesBit;
- global int $gSelectSubdivSurface;
-
- string $selectedObjects[] = `ls -sl -o`;
- string $mainObject;
- string $mainShape;
- int $aSelectedObjectExists = 0;
-
- int $hasChildren = 0;
- int $isValid = 0;
-
- if (size($selectedObjects) > 0)
- {
- $mainObject = $selectedObjects[ (size($selectedObjects) - 1) ];
- $aSelectedObjectExists = 1;
-
- //Check if this node has any children (ie. it is a parent node)
- string $children[] = `listRelatives -c $mainObject`;
- string $shapes[] = `listRelatives -s $mainObject`;
-
- $mainShape = $shapes[0];
-
- if (size($children) > 1)
- {
- $hasChildren = 1;
- }
- else if (size($children) == 1)
- {
- if ($mainShape != $children[0])
- {
- $hasChildren = 1;
- }
- }
- }
-
- string $surface;
-
- string $nurbsSurfaces[] = `filterExpand -ex true
- -sm $gSelectNurbsSurfacesBit $selectedObjects`;
- int $aSelectedNurbsSurfaceExists = 0;
-
- if (size($nurbsSurfaces) > 0)
- {
- if ($hasChildren)
- {
- for ($surface in $nurbsSurfaces)
- {
- if ($mainShape == $surface)
- {
- $isValid = 1;
- break;
- }
- }
- }
- else if ($nurbsSurfaces[ (size($nurbsSurfaces) - 1) ] == $mainObject)
- {
- $isValid = 1;
- }
- $aSelectedNurbsSurfaceExists = 1;
- }
-
- string $subdivSurfaces[] = `filterExpand -ex true
- -sm $gSelectSubdivSurface $selectedObjects`;
- int $aSelectedSubdivSurfaceExists = 0;
-
- if (size($subdivSurfaces) > 0)
- {
- if ($hasChildren)
- {
- for ($surface in $subdivSurfaces)
- {
- if ($mainShape == $surface)
- {
- $isValid = 1;
- break;
- }
- }
- }
- else if ($subdivSurfaces[ (size($subdivSurfaces) - 1) ] == $mainObject)
- {
- $isValid = 1;
- }
- $aSelectedSubdivSurfaceExists = 1;
- }
-
- if ($aSelectedObjectExists)
- {
- if ($aSelectedNurbsSurfaceExists && $isValid)
- {
- // NURBS Surface
- //
- //"Hull" displaySmoothness -hull;
- //"Rough" displaySmoothness -du 0 -dv 0 -pw 4 -ps 1;
- //"Medium" displaySmoothness -du 1 -dv 1 -pw 8 -ps 2;
- //"Fine" displaySmoothness -du 2 -dv 2 -pw 16 -ps 4;
-
- int $smoothness[] = `displaySmoothness -q -du -dv -pw -ps $mainObject`;
- int $isFull[] = `displaySmoothness -q -full $mainObject`;
- int $isHull[] = `displaySmoothness -q -hull $mainObject`;
-
- if (size($smoothness) == 0)
- {
- //Is not a Nurbs/Subdiv surface
- $result = "N/A";
- }
- else if ($isHull[0])
- {
- //Is Hull
- $result = "Hull";
- }
- else if ($smoothness[0] == 0 &&
- $smoothness[1] == 0 &&
- $smoothness[2] == 4 &&
- $smoothness[3] == 1 &&
- $isFull[0])
- {
- //Is Rough
- $result = "Rough";
- }
- else if ($smoothness[0] == 1 &&
- $smoothness[1] == 1 &&
- $smoothness[2] == 8 &&
- $smoothness[3] == 2 &&
- $isFull[0])
- {
- //Is Medium
- $result = "Medium";
- }
- else if ($smoothness[0] == 2 &&
- $smoothness[1] == 2 &&
- $smoothness[2] == 16 &&
- $smoothness[3] == 4 &&
- $isFull[0])
- {
- //Is Fine
- $result = "Fine";
- }
- else
- {
- //Is Custom
- $result = "Custom";
- }
-
- $hasResult = true;
- }
- else if ($aSelectedSubdivSurfaceExists && $isValid)
- {
- //Subdiv Surface
- //
- //"Hull" subdivDisplaySmoothness -s 0;
- //"Rough" subdivDisplaySmoothness -s 1;
- //"Medium" subdivDisplaySmoothness -s 2;
- //"Fine" subdivDisplaySmoothness -s 3;
-
- int $smoothness[] = `subdivDisplaySmoothness -q $mainObject`;
-
- switch ($smoothness[0])
- {
- case 0:
- $result = "Hull";
- case 1:
- $result = "Rough";
- case 2:
- $result = "Medium";
- case 3:
- $result = "Fine";
- default:
- $result = "Custom";
- }
-
- $hasResult = true;
- }
- }
-
- if (!$hasResult)
- {
- //No selected objects or no selected objects of valid type
- $result = "N/A";
- }
-
- return $result;
- }
-
- global proc string objectDetailsInstance()
- {
- string $result;
- int $hasResult = false;
-
- string $selectedObjects[] = `ls -sl`;
- string $mainObject;
- int $aSelectedObjectExists = 0;
-
- if (size($selectedObjects) > 0)
- {
- $mainObject = $selectedObjects[ (size($selectedObjects) - 1) ];
- $aSelectedObjectExists = 1;
- }
-
- if ($aSelectedObjectExists)
- {
- string $mainShape[] = `listRelatives -fullPath -s $mainObject`;
-
- if (size($mainShape))
- {
- string $mainShapeParents[] = `listRelatives -ap $mainShape[0]`;
-
- if (size($mainShapeParents) > 1)
- {
- $result = "Yes";
- }
- else
- {
- $result = "No";
- }
-
- $hasResult = true;
- }
- }
-
- if (!$hasResult)
- {
- //No selected objects
- $result = "N/A";
- }
-
- return $result;
- }
-
- global proc string objectDetailsDisplayLayer()
- {
- string $result;
- int $hasResult = false;
-
- string $selectedObjects[] = `ls -sl -o`;
- string $mainObject;
-
- int $aSelectedObjectExists = 0;
-
- if (size($selectedObjects) > 0)
- {
- $mainObject = $selectedObjects[ (size($selectedObjects) - 1) ];
- $aSelectedObjectExists = 1;
- }
-
- if ($aSelectedObjectExists)
- {
- if (`objExists ($mainObject + ".drawOverride")`)
- {
- string $layerDrawInfo = `connectionInfo -sfd ($mainObject + ".drawOverride")`;
-
- //Now tokenize the layerDrawInfo string
- string $layerStringArray[];
- int $numTokens = `tokenize $layerDrawInfo "." $layerStringArray`;
-
- if (`objExists $layerStringArray[0]`)
- {
- $result = $layerStringArray[0];
- }
- else
- {
- $result = "default";
- }
-
- $hasResult = true;
- }
- }
-
- if (!$hasResult)
- {
- $result = "N/A";
- }
-
- return $result;
- }
-
- //Toggle methods
- //
- global proc setObjectDetailsVisibility(int $visibility)
- {
- if (`headsUpDisplay -ex HUDObjDetBackfaces`)
- {
- headsUpDisplay -e -vis $visibility HUDObjDetBackfaces;
- }
- if (`headsUpDisplay -ex HUDObjDetSmoothness`)
- {
- headsUpDisplay -e -vis $visibility HUDObjDetSmoothness;
- }
- if (`headsUpDisplay -ex HUDObjDetInstance`)
- {
- headsUpDisplay -e -vis $visibility HUDObjDetInstance;
- }
- if (`headsUpDisplay -ex HUDObjDetDispLayer`)
- {
- headsUpDisplay -e -vis $visibility HUDObjDetDispLayer;
- }
- if (`headsUpDisplay -ex HUDObjDetDistFromCam`)
- {
- headsUpDisplay -e -vis $visibility HUDObjDetDistFromCam;
- }
-
- //Update the respective menu item and optionVar
- menuItem -e -cb $visibility objectDetailsItem;
- optionVar -iv "objectDetailsVisibility" $visibility;
- }
-
- global proc setPolyCountVisibility(int $visibility)
- {
- if (`headsUpDisplay -ex HUDPolyCountVerts`)
- {
- headsUpDisplay -e -vis $visibility HUDPolyCountVerts;
- }
- if (`headsUpDisplay -ex HUDPolyCountEdges`)
- {
- headsUpDisplay -e -vis $visibility HUDPolyCountEdges;
- }
- if (`headsUpDisplay -ex HUDPolyCountFaces`)
- {
- headsUpDisplay -e -vis $visibility HUDPolyCountFaces;
- }
- if (`headsUpDisplay -ex HUDPolyCountUVs`)
- {
- headsUpDisplay -e -vis $visibility HUDPolyCountUVs;
- }
-
- //Update the respective menu item and optionVar
- menuItem -e -cb $visibility polyCountItem;
- optionVar -iv "polyCountVisibility" $visibility;
- }
-
- global proc setCameraNamesVisibility(int $visibility)
- {
- if (`headsUpDisplay -ex HUDCameraNames`)
- {
- headsUpDisplay -e -vis $visibility HUDCameraNames;
- }
-
- //Update the respective menu item and optionVar
- menuItem -e -cb $visibility cameraNamesItem;
- optionVar -iv "cameraNamesVisibility" $visibility;
- }
-
- global proc setFrameRateVisibility(int $visibility)
- {
- if (`headsUpDisplay -ex HUDFrameRate`)
- {
- headsUpDisplay -e -vis $visibility HUDFrameRate;
- }
-
- //Update the respective menu item and optionVar
- menuItem -e -cb $visibility frameRateItem;
- optionVar -iv "frameRateVisibility" $visibility;
- }
-
- global proc setViewAxisVisibility(int $visibility)
- {
- if (`headsUpDisplay -ex HUDViewAxis`)
- {
- headsUpDisplay -e -vis $visibility HUDViewAxis;
- }
-
- //Update the respective menu item and optionVar
- menuItem -e -cb $visibility viewAxisItem;
- optionVar -iv "viewAxisVisibility" $visibility;
- }
-
- global proc setAnimationDetailsVisibility(int $visibility)
- {
- if (`headsUpDisplay -ex HUDIKSolverState`)
- {
- headsUpDisplay -e -vis $visibility HUDIKSolverState;
- }
- if (`headsUpDisplay -ex HUDCurrentCharacter`)
- {
- headsUpDisplay -e -vis $visibility HUDCurrentCharacter;
- }
- if (`headsUpDisplay -ex HUDPlaybackSpeed`)
- {
- headsUpDisplay -e -vis $visibility HUDPlaybackSpeed;
- }
-
- // Begin scriptJob to force update of animated ikSolver states.
- //
- global int $gHUDupdateIKScriptJobExists = 0;
- global int $gHUDupdateIKScriptJob = 0;
- if( $visibility ) {
- if( !$gHUDupdateIKScriptJobExists ) {
- if( `headsUpDisplay -exists HUDIKSolverState` ) {
- $gHUDupdateIKScriptJob = `scriptJob -event timeChanged
- "headsUpDisplay -refresh HUDIKSolverState"`;
- $gHUDupdateIKScriptJobExists = 1;
- }
- }
- } else {
- if( $gHUDupdateIKScriptJobExists ) {
- catch( `scriptJob -kill $gHUDupdateIKScriptJob` );
- }
- $gHUDupdateIKScriptJob = 0;
- $gHUDupdateIKScriptJobExists = 0;
- }
- //
- // End scriptJob to force update of animated ikSolver states.
-
- //Update the respective menu item and optionVar
- menuItem -e -cb $visibility animationDetailsItem;
- optionVar -iv "animationDetailsVisibility" $visibility;
- }
-
- global proc string animationDetailsIKFK()
- //
- // Description:
- // Returns a string describing the solver enable state of the
- // selected joint chains.
- //
- // There are five different returned strings:
- // "None Selected" : No joints or ikHandles are selected.
- // "On" : The selected items have their solver enabled.
- // "Off" : The selected items have their solver disabled.
- // "No Solver" : No solver on the selcted joints.
- // "Mixed" : Some of the selected items have their solvers
- // enabled and others have their solvers disabled.
- //
- {
- int $lastMenuSwitchState = `optionVar -q ikFKSwitchState`;
-
- // There are five different returned values from ikFKSolverState()
- // 0 : No joints or ikHandles are selected.
- // 1 : The selected items have their solver enabled.
- // 2 : The selected items have their solver disabled.
- // 3 : No solver on the selcted joints.
- // 4 : Some of the selected items have their solvers
- // enabled and others have their solvers disabled.
- //
- int $solverState = ikFKSolverState(`ls -sl`);
-
- string $result;
- switch ($solverState) {
- case 1:
- float $blendValue = ikFkBlendValue(`ls -sl`);
- if ($blendValue > 0.0) {
- $result = $blendValue;
- } else {
- $result = "Mixed";
- }
- if (on != $lastMenuSwitchState &&
- `exists updateIKFKCheckBox`) {
- updateIKFKCheckBox(on);
- }
- break;
- case 2:
- $result = "Off";
- if (off != $lastMenuSwitchState &&
- `exists updateIKFKCheckBox`) {
- updateIKFKCheckBox(off);
- }
- break;
- case 3:
- $result = "No Solver";
- break;
- case 4:
- $result = "Mixed";
- if (!$lastMenuSwitchState &&
- `exists updateIKFKCheckBox`) {
- updateIKFKCheckBox(on);
- }
- break;
- case 0:
- default:
- $result = "No Solver";
- break;
- }
-
- return $result;
- }
-
- global proc string animationDetailsCurrentCharacter()
- {
- string $text = "No Character";
-
- string $currentCharacters[] = currentCharacters();
- int $size = size( $currentCharacters );
-
- if ( $size > 0 ) {
- if ( $size == 1 ) {
- $text = $currentCharacters[0];
- } else {
- $text = "multiple";
- }
- }
-
- return $text;
- }
-
- global proc string animationDetailsPlaybackSpeed()
- {
- string $text = "N/A";
- float $speed = `playbackOptions -q -playbackSpeed`;
-
- string $unit = `currentUnit -q -time`;
- float $fps = 0;
-
- if( $unit == "game" ) {
- $fps = 15;
- } else if( $unit == "film" ) {
- $fps = 24;
- } else if( $unit == "pal" ) {
- $fps = 25;
- } else if( $unit == "ntsc" ) {
- $fps = 30;
- } else if( $unit == "show" ) {
- $fps = 48;
- } else if( $unit == "palf" ) {
- $fps = 50;
- } else if( $unit == "ntscf" ) {
- $fps = 60;
- }
-
- if (equivalent($speed,0.0)) {
- $text = "Every Frame ";
- } else if (equivalent($speed,0.5)) {
- $text = "Half ";
- } else if (equivalent($speed,1.0)) {
- $text = "Real";
- } else if (equivalent($speed,2.0)) {
- $text = "Twice ";
- } else {
- $text = "Other ";
- }
-
- float $rate = $fps * $speed;
- if (!equivalent($rate, 0.0)) {
- $text += (" [" + ($rate) + " fps]");
- }
-
- return $text;
- }
-
- global proc updateCurrentCharacterHUD()
- //
- // Description:
- // The global proc to update the current character HUD.
- //
- {
- // This will update the display for the character field.
- //
- if (`headsUpDisplay -ex HUDCurrentCharacter`)
- {
- headsUpDisplay -refresh HUDCurrentCharacter;
- }
- }
-
- global proc updatePlaybackSpeedHUD()
- {
- if (`headsUpDisplay -ex HUDPlaybackSpeed`)
- {
- headsUpDisplay -refresh HUDPlaybackSpeed;
- }
- }
-